package com.zjitc.chapter13.controller;

import com.zjitc.chapter13.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
@Controller
public class ExcptionController {
    @RequestMapping("/showNullPointer")
    public void showNullPointer() {
        System.out.println("ExcptionController.showNullPointer");
        List list = null;
        System.out.println(list.add("13"));
    }
    @RequestMapping("/showIOExcption")
    public void showIOExcption() throws IOException {
        System.out.println("ExcptionController.showIOExcption");
        FileInputStream fileInputStream = new FileInputStream("a.txt");
    }
    @RequestMapping("/showArithmeticExcption")
    public void showArithmeticExcption() {
        System.out.println("ExcptionController.showArithmeticExcption");
        int i = 1/0;
    }
    @RequestMapping("/showMyExcption")
    public void showMyExcption() throws MyException {
        System.out.println("ExcptionController.showMyExcption");
        throw new MyException("自定义异常");

    }
}
